package red.stu.window.editor;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.JTree;

import com.sun.jna.Native;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef.HWND;

import red.stu.window.editor.code.CodeEditor;
import red.stu.window.editor.code.CodeEditor.Callback;

public class CodeEditorWindow extends JFrame {

	public CodeEditor codeEditor;
	public JTree libTree;
	
	public HWND codeEditorHwnd;

	public CodeEditorWindow(Callback callback) {
		Dimension dim = getToolkit().getScreenSize();
		this.setBounds(dim.width / 4, dim.height / 4, dim.width / 2, dim.height / 2);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.setUndecorated(true);
		this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
		// libTree
		libTree = new JTree();
		// CodeEditor
		codeEditor = new CodeEditor(callback);
		this.getContentPane().add(codeEditor.getScrollPane());
		
		// this.setVisible(true);
	}
	
	/**
	 * 刷新高亮提示
	 */
	public void refreshCodeEditorText() {
		codeEditor.onTextUpdate();
	}
	
	public static void main(String[] args) {
		CodeEditorWindow ide = new CodeEditorWindow(new Callback() {
			@Override
			public void onEscKeyPressed() {
				System.out.println("keyPressed: ESC");
			}
		});
		ide.setVisible(true);
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ide.setVisible(true);
	}

}
